package com.library.servlet;
import com.library.bean.Book;

import com.library.service.BookService;
import com.library.service.impl.BookServiceImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "BookServlet", value = "/BookServlet")
public class BookServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        BookService bookService=new BookServiceImpl();

        List<Book> books=bookService.selectAll();
        request.setAttribute("list",books);

        request.getRequestDispatcher("index.jsp").forward(request, response);;


    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request,response);
    }
}
